package com.nbsaas.boot.scm.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.Table;
import lombok.Data;
import org.hibernate.annotations.Comment;

import java.math.BigDecimal;
import java.util.Date;

@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "采购付款", model = "采购付款")
@Entity
@Table(name = "bs_purchase_payment")
@Comment("采购付款表")
public class PurchasePayment extends AbstractEntity {

    @Comment("付款单号")
    @SearchItem(name = "paymentNo", key = "paymentNo", label = "付款单号")
    @FormField(title = "付款单号", sortNum = "1", grid = true, required = true)
    @Column(length = 50, nullable = false, unique = true)
    private String paymentNo;

    @Comment("付款标题")
    @SearchItem(name = "title", key = "title", label = "付款标题")
    @FormField(title = "付款标题", sortNum = "2", grid = true, required = true)
    @Column(length = 200, nullable = false)
    private String title;

    @Comment("供应商ID")
    @FormField(title = "供应商", sortNum = "3", grid = true, type = InputType.select, required = true)
    private Long supplierId;

    @Comment("供应商编码")
    @FormField(title = "供应商编码", sortNum = "4", grid = true)
    @Column(length = 50)
    private String supplierCode;

    @Comment("供应商名称")
    @FormField(title = "供应商名称", sortNum = "5", grid = true)
    @Column(length = 200)
    private String supplierName;

    @Comment("采购订单ID")
    @FormField(title = "采购订单", sortNum = "6", grid = true, type = InputType.select)
    private Long purchaseOrderId;

    @Comment("采购订单编号")
    @FormField(title = "采购订单编号", sortNum = "7", grid = true)
    @Column(length = 50)
    private String purchaseOrderNo;

    @Comment("采购合同ID")
    @FormField(title = "采购合同", sortNum = "8", grid = true, type = InputType.select)
    private Long purchaseContractId;

    @Comment("采购合同编号")
    @FormField(title = "采购合同编号", sortNum = "9", grid = true)
    @Column(length = 50)
    private String purchaseContractNo;

    @Comment("付款类型")
    @FormField(title = "付款类型", sortNum = "10", grid = true, type = InputType.select)
    @Column(length = 50)
    private String paymentType; // ADVANCE-预付款, PROGRESS-进度款, FINAL-尾款, REFUND-退款

    @Comment("付款方式")
    @FormField(title = "付款方式", sortNum = "11", grid = true, type = InputType.select)
    @Column(length = 50)
    private String paymentMethod; // BANK_TRANSFER-银行转账, CHECK-支票, CASH-现金, ONLINE-在线支付

    @Comment("付款状态")
    @FormField(title = "付款状态", sortNum = "12", grid = true, type = InputType.select)
    @Column(length = 20)
    private String paymentStatus; // PENDING-待付款, PROCESSING-付款中, COMPLETED-已付款, FAILED-付款失败, CANCELLED-已取消

    @Comment("审批状态")
    @FormField(title = "审批状态", sortNum = "13", grid = true, type = InputType.select)
    @Column(length = 20)
    private String approvalStatus; // PENDING-待审批, APPROVED-已审批, REJECTED-已拒绝

    @Comment("付款金额")
    @FormField(title = "付款金额", sortNum = "14", grid = true, type = InputType.el_input_number, required = true, sort = true)
    @Column(precision = 15, scale = 2, nullable = false)
    private BigDecimal paymentAmount;

    @Comment("已付金额")
    @FormField(title = "已付金额", sortNum = "15", grid = true, type = InputType.el_input_number)
    @Column(precision = 15, scale = 2)
    private BigDecimal paidAmount;

    @Comment("未付金额")
    @FormField(title = "未付金额", sortNum = "16", grid = true, type = InputType.el_input_number)
    @Column(precision = 15, scale = 2)
    private BigDecimal unpaidAmount;

    @Comment("计划付款日期")
    @FormField(title = "计划付款日期", sortNum = "17", type = InputType.date, grid = true, required = true)
    private Date plannedPaymentDate;

    @Comment("实际付款日期")
    @FormField(title = "实际付款日期", sortNum = "18", type = InputType.date, grid = true)
    private Date actualPaymentDate;

    @Comment("银行账户")
    @FormField(title = "银行账户", sortNum = "19", grid = true)
    @Column(length = 100)
    private String bankAccount;

    @Comment("银行名称")
    @FormField(title = "银行名称", sortNum = "20", grid = true)
    @Column(length = 100)
    private String bankName;

    @Comment("收款人")
    @FormField(title = "收款人", sortNum = "21", grid = true)
    @Column(length = 100)
    private String payee;

    @Comment("付款说明")
    @FormField(title = "付款说明", sortNum = "22", type = InputType.textarea)
    @Column(columnDefinition = "text")
    private String paymentDescription;

    @Comment("审批意见")
    @FormField(title = "审批意见", sortNum = "23", type = InputType.textarea)
    @Column(columnDefinition = "text")
    private String approvalComment;

    @Comment("审批人ID")
    @FormField(title = "审批人", sortNum = "24", grid = true, type = InputType.select)
    private Long approverId;

    @Comment("审批人姓名")
    @FormField(title = "审批人姓名", sortNum = "25", grid = true)
    @Column(length = 100)
    private String approverName;

    @Comment("审批时间")
    @FormField(title = "审批时间", sortNum = "26", type = InputType.date, grid = true)
    private Date approvalTime;

    @Comment("备注")
    @FormField(title = "备注", sortNum = "27", type = InputType.textarea)
    @Column(columnDefinition = "text")
    private String remark;
} 